//
//  BaseModel.m
//  Parson
//
//  Created by lanou3g on 16/5/4.
//  Copyright © 2016年 Mango. All rights reserved.
//

#import "BaseModel.h"
#import "LeftModel.h"
#import "TopModel.h"
#import "VideoModel.h"
#import "GifModel.h"
@implementation BaseModel
- (CGFloat)cellHeight {
    return 0;
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}


- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"id"]) {
        self.ID = [value integerValue];
    }
}


+ (instancetype)baseModelWithDictionary:(NSDictionary *)dict {
    NSMutableArray *keys = [NSMutableArray array];
    for (NSString *key in dict) {
        [keys addObject:key];
    }
   
    if ([keys containsObject:@"type"] && [dict[@"type"] isEqual:@1]) {
        TopModel *topModel = [TopModel new];
        [topModel setValuesForKeysWithDictionary:dict];
        return topModel;
    }else if ([keys containsObject:@"src"]) {
        VideoModel *videoModel = [VideoModel new];
        [videoModel setValuesForKeysWithDictionary:dict];
        return videoModel;
    }else if ([keys containsObject:@"gif"]) {
        GifModel *gifModel = [GifModel new];
        [gifModel setValuesForKeysWithDictionary:dict];
        return gifModel;
    }else {
        LeftModel *leftModel = [LeftModel new];
        [leftModel setValuesForKeysWithDictionary:dict];
        return leftModel;
    }
   
}

@end
